{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "__Author:__ Bram Van de Sande\n",
    "\n",
    "__Date:__ 22 MAR 2018\n",
    "\n",
    "__Outline:__ Assess the AUCell implementation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "from pyscenic.genesig import GeneSignature\n",
    "from pyscenic.aucell import aucell, derive_auc_threshold, create_rankings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext memory_profiler"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# A module from GeneSigDB (C6)\n",
    "GMT_FNAME = 'signatures.hgnc.gmt'\n",
    "# An expression matrix from GEO\n",
    "EXPRESSION_MTX_FNAME = 'GSE103322.mtx.tsv' # Gene expression as (cell, gene) - matrix."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "189"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "signatures = GeneSignature.from_gmt(GMT_FNAME, 'HGNC', field_separator='\\t', gene_separator='\\t')\n",
    "len(signatures)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5902, 20684)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex_matrix = pd.read_csv(EXPRESSION_MTX_FNAME, sep='\\t', header=0, index_col=0).T\n",
    "ex_matrix.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "peak memory: 5733.45 MiB, increment: 4447.32 MiB\n"
     ]
    }
   ],
   "source": [
    "%memit create_rankings(ex_matrix)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12.1 s ± 0 ns per loop (mean ± std. dev. of 1 run, 1 loop each)\n"
     ]
    }
   ],
   "source": [
    "%timeit -n1 -r1 create_rankings(ex_matrix)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.01    0.092294\n",
       "0.05    0.102497\n",
       "0.10    0.112067\n",
       "0.50    0.170712\n",
       "1.00    0.632421\n",
       "dtype: float64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "percentiles = derive_auc_threshold(ex_matrix)\n",
    "percentiles"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Regulome</th>\n",
       "      <th>GLI1_UP.V1_DN</th>\n",
       "      <th>GLI1_UP.V1_UP</th>\n",
       "      <th>E2F1_UP.V1_DN</th>\n",
       "      <th>E2F1_UP.V1_UP</th>\n",
       "      <th>EGFR_UP.V1_DN</th>\n",
       "      <th>EGFR_UP.V1_UP</th>\n",
       "      <th>ERB2_UP.V1_DN</th>\n",
       "      <th>ERB2_UP.V1_UP</th>\n",
       "      <th>GCNP_SHH_UP_EARLY.V1_DN</th>\n",
       "      <th>GCNP_SHH_UP_EARLY.V1_UP</th>\n",
       "      <th>...</th>\n",
       "      <th>KRAS.KIDNEY_UP.V1_DN</th>\n",
       "      <th>KRAS.KIDNEY_UP.V1_UP</th>\n",
       "      <th>KRAS.LUNG_UP.V1_DN</th>\n",
       "      <th>KRAS.LUNG_UP.V1_UP</th>\n",
       "      <th>KRAS.LUNG.BREAST_UP.V1_DN</th>\n",
       "      <th>KRAS.LUNG.BREAST_UP.V1_UP</th>\n",
       "      <th>KRAS.PROSTATE_UP.V1_DN</th>\n",
       "      <th>KRAS.PROSTATE_UP.V1_UP</th>\n",
       "      <th>LEF1_UP.V1_DN</th>\n",
       "      <th>LEF1_UP.V1_UP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Cell</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>HN28_P15_D06_S330_comb</th>\n",
       "      <td>0.099154</td>\n",
       "      <td>0.133946</td>\n",
       "      <td>0.100587</td>\n",
       "      <td>0.065074</td>\n",
       "      <td>0.069673</td>\n",
       "      <td>0.107095</td>\n",
       "      <td>0.051168</td>\n",
       "      <td>0.066695</td>\n",
       "      <td>0.080446</td>\n",
       "      <td>0.025027</td>\n",
       "      <td>...</td>\n",
       "      <td>0.021262</td>\n",
       "      <td>0.051473</td>\n",
       "      <td>0.026772</td>\n",
       "      <td>0.008190</td>\n",
       "      <td>0.045178</td>\n",
       "      <td>0.033161</td>\n",
       "      <td>0.028602</td>\n",
       "      <td>0.024628</td>\n",
       "      <td>0.054168</td>\n",
       "      <td>0.076753</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN28_P6_G05_S173_comb</th>\n",
       "      <td>0.079136</td>\n",
       "      <td>0.118619</td>\n",
       "      <td>0.105842</td>\n",
       "      <td>0.028522</td>\n",
       "      <td>0.054226</td>\n",
       "      <td>0.083728</td>\n",
       "      <td>0.046880</td>\n",
       "      <td>0.070569</td>\n",
       "      <td>0.090524</td>\n",
       "      <td>0.056925</td>\n",
       "      <td>...</td>\n",
       "      <td>0.016059</td>\n",
       "      <td>0.062782</td>\n",
       "      <td>0.015966</td>\n",
       "      <td>0.013072</td>\n",
       "      <td>0.037452</td>\n",
       "      <td>0.034941</td>\n",
       "      <td>0.025110</td>\n",
       "      <td>0.022847</td>\n",
       "      <td>0.042237</td>\n",
       "      <td>0.070310</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P14_D11_S239_comb</th>\n",
       "      <td>0.063197</td>\n",
       "      <td>0.098985</td>\n",
       "      <td>0.058575</td>\n",
       "      <td>0.044917</td>\n",
       "      <td>0.047802</td>\n",
       "      <td>0.051754</td>\n",
       "      <td>0.033969</td>\n",
       "      <td>0.030310</td>\n",
       "      <td>0.058901</td>\n",
       "      <td>0.045749</td>\n",
       "      <td>...</td>\n",
       "      <td>0.010676</td>\n",
       "      <td>0.010213</td>\n",
       "      <td>0.017624</td>\n",
       "      <td>0.005473</td>\n",
       "      <td>0.026113</td>\n",
       "      <td>0.008704</td>\n",
       "      <td>0.007087</td>\n",
       "      <td>0.004038</td>\n",
       "      <td>0.056571</td>\n",
       "      <td>0.012875</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P14_H05_S281_comb</th>\n",
       "      <td>0.048530</td>\n",
       "      <td>0.064955</td>\n",
       "      <td>0.111510</td>\n",
       "      <td>0.036309</td>\n",
       "      <td>0.081354</td>\n",
       "      <td>0.090282</td>\n",
       "      <td>0.065022</td>\n",
       "      <td>0.065199</td>\n",
       "      <td>0.058168</td>\n",
       "      <td>0.056469</td>\n",
       "      <td>...</td>\n",
       "      <td>0.016900</td>\n",
       "      <td>0.046019</td>\n",
       "      <td>0.007634</td>\n",
       "      <td>0.018416</td>\n",
       "      <td>0.024590</td>\n",
       "      <td>0.046674</td>\n",
       "      <td>0.029752</td>\n",
       "      <td>0.026695</td>\n",
       "      <td>0.044156</td>\n",
       "      <td>0.095498</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P25_H09_S189_comb</th>\n",
       "      <td>0.103888</td>\n",
       "      <td>0.106164</td>\n",
       "      <td>0.090400</td>\n",
       "      <td>0.033373</td>\n",
       "      <td>0.063693</td>\n",
       "      <td>0.098212</td>\n",
       "      <td>0.056039</td>\n",
       "      <td>0.056896</td>\n",
       "      <td>0.043951</td>\n",
       "      <td>0.032995</td>\n",
       "      <td>...</td>\n",
       "      <td>0.036520</td>\n",
       "      <td>0.022551</td>\n",
       "      <td>0.048584</td>\n",
       "      <td>0.018322</td>\n",
       "      <td>0.046580</td>\n",
       "      <td>0.020300</td>\n",
       "      <td>0.026427</td>\n",
       "      <td>0.011657</td>\n",
       "      <td>0.044799</td>\n",
       "      <td>0.034251</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 189 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "Regulome                GLI1_UP.V1_DN  GLI1_UP.V1_UP  E2F1_UP.V1_DN  \\\n",
       "Cell                                                                  \n",
       "HN28_P15_D06_S330_comb       0.099154       0.133946       0.100587   \n",
       "HN28_P6_G05_S173_comb        0.079136       0.118619       0.105842   \n",
       "HN26_P14_D11_S239_comb       0.063197       0.098985       0.058575   \n",
       "HN26_P14_H05_S281_comb       0.048530       0.064955       0.111510   \n",
       "HN26_P25_H09_S189_comb       0.103888       0.106164       0.090400   \n",
       "\n",
       "Regulome                E2F1_UP.V1_UP  EGFR_UP.V1_DN  EGFR_UP.V1_UP  \\\n",
       "Cell                                                                  \n",
       "HN28_P15_D06_S330_comb       0.065074       0.069673       0.107095   \n",
       "HN28_P6_G05_S173_comb        0.028522       0.054226       0.083728   \n",
       "HN26_P14_D11_S239_comb       0.044917       0.047802       0.051754   \n",
       "HN26_P14_H05_S281_comb       0.036309       0.081354       0.090282   \n",
       "HN26_P25_H09_S189_comb       0.033373       0.063693       0.098212   \n",
       "\n",
       "Regulome                ERB2_UP.V1_DN  ERB2_UP.V1_UP  GCNP_SHH_UP_EARLY.V1_DN  \\\n",
       "Cell                                                                            \n",
       "HN28_P15_D06_S330_comb       0.051168       0.066695                 0.080446   \n",
       "HN28_P6_G05_S173_comb        0.046880       0.070569                 0.090524   \n",
       "HN26_P14_D11_S239_comb       0.033969       0.030310                 0.058901   \n",
       "HN26_P14_H05_S281_comb       0.065022       0.065199                 0.058168   \n",
       "HN26_P25_H09_S189_comb       0.056039       0.056896                 0.043951   \n",
       "\n",
       "Regulome                GCNP_SHH_UP_EARLY.V1_UP      ...        \\\n",
       "Cell                                                 ...         \n",
       "HN28_P15_D06_S330_comb                 0.025027      ...         \n",
       "HN28_P6_G05_S173_comb                  0.056925      ...         \n",
       "HN26_P14_D11_S239_comb                 0.045749      ...         \n",
       "HN26_P14_H05_S281_comb                 0.056469      ...         \n",
       "HN26_P25_H09_S189_comb                 0.032995      ...         \n",
       "\n",
       "Regulome                KRAS.KIDNEY_UP.V1_DN  KRAS.KIDNEY_UP.V1_UP  \\\n",
       "Cell                                                                 \n",
       "HN28_P15_D06_S330_comb              0.021262              0.051473   \n",
       "HN28_P6_G05_S173_comb               0.016059              0.062782   \n",
       "HN26_P14_D11_S239_comb              0.010676              0.010213   \n",
       "HN26_P14_H05_S281_comb              0.016900              0.046019   \n",
       "HN26_P25_H09_S189_comb              0.036520              0.022551   \n",
       "\n",
       "Regulome                KRAS.LUNG_UP.V1_DN  KRAS.LUNG_UP.V1_UP  \\\n",
       "Cell                                                             \n",
       "HN28_P15_D06_S330_comb            0.026772            0.008190   \n",
       "HN28_P6_G05_S173_comb             0.015966            0.013072   \n",
       "HN26_P14_D11_S239_comb            0.017624            0.005473   \n",
       "HN26_P14_H05_S281_comb            0.007634            0.018416   \n",
       "HN26_P25_H09_S189_comb            0.048584            0.018322   \n",
       "\n",
       "Regulome                KRAS.LUNG.BREAST_UP.V1_DN  KRAS.LUNG.BREAST_UP.V1_UP  \\\n",
       "Cell                                                                           \n",
       "HN28_P15_D06_S330_comb                   0.045178                   0.033161   \n",
       "HN28_P6_G05_S173_comb                    0.037452                   0.034941   \n",
       "HN26_P14_D11_S239_comb                   0.026113                   0.008704   \n",
       "HN26_P14_H05_S281_comb                   0.024590                   0.046674   \n",
       "HN26_P25_H09_S189_comb                   0.046580                   0.020300   \n",
       "\n",
       "Regulome                KRAS.PROSTATE_UP.V1_DN  KRAS.PROSTATE_UP.V1_UP  \\\n",
       "Cell                                                                     \n",
       "HN28_P15_D06_S330_comb                0.028602                0.024628   \n",
       "HN28_P6_G05_S173_comb                 0.025110                0.022847   \n",
       "HN26_P14_D11_S239_comb                0.007087                0.004038   \n",
       "HN26_P14_H05_S281_comb                0.029752                0.026695   \n",
       "HN26_P25_H09_S189_comb                0.026427                0.011657   \n",
       "\n",
       "Regulome                LEF1_UP.V1_DN  LEF1_UP.V1_UP  \n",
       "Cell                                                  \n",
       "HN28_P15_D06_S330_comb       0.054168       0.076753  \n",
       "HN28_P6_G05_S173_comb        0.042237       0.070310  \n",
       "HN26_P14_D11_S239_comb       0.056571       0.012875  \n",
       "HN26_P14_H05_S281_comb       0.044156       0.095498  \n",
       "HN26_P25_H09_S189_comb       0.044799       0.034251  \n",
       "\n",
       "[5 rows x 189 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aucs_mtx = aucell(ex_matrix, signatures, auc_threshold=percentiles[0.01], num_cores=8)\n",
    "aucs_mtx.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>FASTKD2</th>\n",
       "      <th>IFNA1</th>\n",
       "      <th>SACS</th>\n",
       "      <th>TAS2R14</th>\n",
       "      <th>SPIC</th>\n",
       "      <th>BRD1</th>\n",
       "      <th>TPM4</th>\n",
       "      <th>LAMC1</th>\n",
       "      <th>TTTY1B</th>\n",
       "      <th>PPYR1</th>\n",
       "      <th>...</th>\n",
       "      <th>FBLN5</th>\n",
       "      <th>BBS12</th>\n",
       "      <th>CDK7</th>\n",
       "      <th>HDAC4</th>\n",
       "      <th>SLC23A1</th>\n",
       "      <th>TEDDM1</th>\n",
       "      <th>FOXQ1</th>\n",
       "      <th>FAM168B</th>\n",
       "      <th>NPLOC4</th>\n",
       "      <th>DCP2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>HN28_P15_D06_S330_comb</th>\n",
       "      <td>3941</td>\n",
       "      <td>3942</td>\n",
       "      <td>3943</td>\n",
       "      <td>3944</td>\n",
       "      <td>3945</td>\n",
       "      <td>3946</td>\n",
       "      <td>34</td>\n",
       "      <td>1265</td>\n",
       "      <td>3947</td>\n",
       "      <td>3948</td>\n",
       "      <td>...</td>\n",
       "      <td>20674</td>\n",
       "      <td>20675</td>\n",
       "      <td>20676</td>\n",
       "      <td>20677</td>\n",
       "      <td>20678</td>\n",
       "      <td>20679</td>\n",
       "      <td>20680</td>\n",
       "      <td>20681</td>\n",
       "      <td>20682</td>\n",
       "      <td>20683</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN28_P6_G05_S173_comb</th>\n",
       "      <td>2511</td>\n",
       "      <td>2512</td>\n",
       "      <td>2513</td>\n",
       "      <td>2514</td>\n",
       "      <td>2515</td>\n",
       "      <td>2516</td>\n",
       "      <td>1156</td>\n",
       "      <td>1187</td>\n",
       "      <td>2517</td>\n",
       "      <td>2518</td>\n",
       "      <td>...</td>\n",
       "      <td>20675</td>\n",
       "      <td>20676</td>\n",
       "      <td>444</td>\n",
       "      <td>20677</td>\n",
       "      <td>20678</td>\n",
       "      <td>20679</td>\n",
       "      <td>20680</td>\n",
       "      <td>20681</td>\n",
       "      <td>20682</td>\n",
       "      <td>20683</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P14_D11_S239_comb</th>\n",
       "      <td>2017</td>\n",
       "      <td>6430</td>\n",
       "      <td>4038</td>\n",
       "      <td>6431</td>\n",
       "      <td>6432</td>\n",
       "      <td>3049</td>\n",
       "      <td>6433</td>\n",
       "      <td>6434</td>\n",
       "      <td>6435</td>\n",
       "      <td>6436</td>\n",
       "      <td>...</td>\n",
       "      <td>20678</td>\n",
       "      <td>20679</td>\n",
       "      <td>5210</td>\n",
       "      <td>3965</td>\n",
       "      <td>20680</td>\n",
       "      <td>20681</td>\n",
       "      <td>20682</td>\n",
       "      <td>3218</td>\n",
       "      <td>4353</td>\n",
       "      <td>20683</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P14_H05_S281_comb</th>\n",
       "      <td>2560</td>\n",
       "      <td>3162</td>\n",
       "      <td>3163</td>\n",
       "      <td>3164</td>\n",
       "      <td>3165</td>\n",
       "      <td>3166</td>\n",
       "      <td>246</td>\n",
       "      <td>1500</td>\n",
       "      <td>3167</td>\n",
       "      <td>3168</td>\n",
       "      <td>...</td>\n",
       "      <td>20675</td>\n",
       "      <td>20676</td>\n",
       "      <td>20677</td>\n",
       "      <td>20678</td>\n",
       "      <td>20679</td>\n",
       "      <td>20680</td>\n",
       "      <td>20681</td>\n",
       "      <td>20682</td>\n",
       "      <td>20683</td>\n",
       "      <td>1555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P25_H09_S189_comb</th>\n",
       "      <td>4777</td>\n",
       "      <td>6819</td>\n",
       "      <td>6820</td>\n",
       "      <td>6821</td>\n",
       "      <td>6822</td>\n",
       "      <td>6823</td>\n",
       "      <td>1608</td>\n",
       "      <td>6824</td>\n",
       "      <td>6825</td>\n",
       "      <td>6826</td>\n",
       "      <td>...</td>\n",
       "      <td>20676</td>\n",
       "      <td>20677</td>\n",
       "      <td>1234</td>\n",
       "      <td>3074</td>\n",
       "      <td>20678</td>\n",
       "      <td>20679</td>\n",
       "      <td>20680</td>\n",
       "      <td>20681</td>\n",
       "      <td>20682</td>\n",
       "      <td>20683</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 20684 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                        FASTKD2  IFNA1  SACS  TAS2R14  SPIC  BRD1  TPM4  \\\n",
       "HN28_P15_D06_S330_comb     3941   3942  3943     3944  3945  3946    34   \n",
       "HN28_P6_G05_S173_comb      2511   2512  2513     2514  2515  2516  1156   \n",
       "HN26_P14_D11_S239_comb     2017   6430  4038     6431  6432  3049  6433   \n",
       "HN26_P14_H05_S281_comb     2560   3162  3163     3164  3165  3166   246   \n",
       "HN26_P25_H09_S189_comb     4777   6819  6820     6821  6822  6823  1608   \n",
       "\n",
       "                        LAMC1  TTTY1B  PPYR1  ...    FBLN5  BBS12   CDK7  \\\n",
       "HN28_P15_D06_S330_comb   1265    3947   3948  ...    20674  20675  20676   \n",
       "HN28_P6_G05_S173_comb    1187    2517   2518  ...    20675  20676    444   \n",
       "HN26_P14_D11_S239_comb   6434    6435   6436  ...    20678  20679   5210   \n",
       "HN26_P14_H05_S281_comb   1500    3167   3168  ...    20675  20676  20677   \n",
       "HN26_P25_H09_S189_comb   6824    6825   6826  ...    20676  20677   1234   \n",
       "\n",
       "                        HDAC4  SLC23A1  TEDDM1  FOXQ1  FAM168B  NPLOC4   DCP2  \n",
       "HN28_P15_D06_S330_comb  20677    20678   20679  20680    20681   20682  20683  \n",
       "HN28_P6_G05_S173_comb   20677    20678   20679  20680    20681   20682  20683  \n",
       "HN26_P14_D11_S239_comb   3965    20680   20681  20682     3218    4353  20683  \n",
       "HN26_P14_H05_S281_comb  20678    20679   20680  20681    20682   20683   1555  \n",
       "HN26_P25_H09_S189_comb   3074    20678   20679  20680    20681   20682  20683  \n",
       "\n",
       "[5 rows x 20684 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_rnk = create_rankings(ex_matrix)\n",
    "df_rnk.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5902, 20684)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_rnk.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SNORD113-9</th>\n",
       "      <th>MAGEB16</th>\n",
       "      <th>SNORA49</th>\n",
       "      <th>MIR26A1</th>\n",
       "      <th>MIR485</th>\n",
       "      <th>MIR3909</th>\n",
       "      <th>TTTY23</th>\n",
       "      <th>MIR519E</th>\n",
       "      <th>C10orf53</th>\n",
       "      <th>MIR3684</th>\n",
       "      <th>...</th>\n",
       "      <th>GAPDH</th>\n",
       "      <th>UBB</th>\n",
       "      <th>FTL</th>\n",
       "      <th>RPL7</th>\n",
       "      <th>MTRNR2L8</th>\n",
       "      <th>FTH1</th>\n",
       "      <th>ACTB</th>\n",
       "      <th>TMSB4X</th>\n",
       "      <th>MTRNR2L2</th>\n",
       "      <th>B2M</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>HN28_P15_D06_S330_comb</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.945653</td>\n",
       "      <td>0.842134</td>\n",
       "      <td>0.833173</td>\n",
       "      <td>0.824638</td>\n",
       "      <td>1.093898</td>\n",
       "      <td>0.831537</td>\n",
       "      <td>1.072929</td>\n",
       "      <td>0.917554</td>\n",
       "      <td>1.167422</td>\n",
       "      <td>1.061845</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN28_P6_G05_S173_comb</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.971751</td>\n",
       "      <td>0.862773</td>\n",
       "      <td>0.968909</td>\n",
       "      <td>0.953399</td>\n",
       "      <td>1.124328</td>\n",
       "      <td>0.923339</td>\n",
       "      <td>0.996584</td>\n",
       "      <td>0.954457</td>\n",
       "      <td>1.170053</td>\n",
       "      <td>0.940295</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P14_D11_S239_comb</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>1.100170</td>\n",
       "      <td>0.821669</td>\n",
       "      <td>0.956934</td>\n",
       "      <td>0.953593</td>\n",
       "      <td>1.119356</td>\n",
       "      <td>0.952363</td>\n",
       "      <td>0.821784</td>\n",
       "      <td>0.819039</td>\n",
       "      <td>1.194907</td>\n",
       "      <td>0.820894</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P14_H05_S281_comb</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.705589</td>\n",
       "      <td>0.977141</td>\n",
       "      <td>0.941196</td>\n",
       "      <td>0.881868</td>\n",
       "      <td>1.049143</td>\n",
       "      <td>0.954018</td>\n",
       "      <td>0.916003</td>\n",
       "      <td>0.984108</td>\n",
       "      <td>1.171271</td>\n",
       "      <td>1.080044</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P25_H09_S189_comb</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>1.001442</td>\n",
       "      <td>0.850375</td>\n",
       "      <td>0.874529</td>\n",
       "      <td>0.973545</td>\n",
       "      <td>1.156655</td>\n",
       "      <td>0.938911</td>\n",
       "      <td>0.720506</td>\n",
       "      <td>0.857750</td>\n",
       "      <td>1.227803</td>\n",
       "      <td>0.934479</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 20684 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                        SNORD113-9  MAGEB16  SNORA49  MIR26A1  MIR485  \\\n",
       "HN28_P15_D06_S330_comb         0.0      0.0      0.0      0.0     0.0   \n",
       "HN28_P6_G05_S173_comb          0.0      0.0      0.0      0.0     0.0   \n",
       "HN26_P14_D11_S239_comb         0.0      0.0      0.0      0.0     0.0   \n",
       "HN26_P14_H05_S281_comb         0.0      0.0      0.0      0.0     0.0   \n",
       "HN26_P25_H09_S189_comb         0.0      0.0      0.0      0.0     0.0   \n",
       "\n",
       "                        MIR3909  TTTY23  MIR519E  C10orf53  MIR3684    ...     \\\n",
       "HN28_P15_D06_S330_comb      0.0     0.0      0.0       0.0      0.0    ...      \n",
       "HN28_P6_G05_S173_comb       0.0     0.0      0.0       0.0      0.0    ...      \n",
       "HN26_P14_D11_S239_comb      0.0     0.0      0.0       0.0      0.0    ...      \n",
       "HN26_P14_H05_S281_comb      0.0     0.0      0.0       0.0      0.0    ...      \n",
       "HN26_P25_H09_S189_comb      0.0     0.0      0.0       0.0      0.0    ...      \n",
       "\n",
       "                           GAPDH       UBB       FTL      RPL7  MTRNR2L8  \\\n",
       "HN28_P15_D06_S330_comb  0.945653  0.842134  0.833173  0.824638  1.093898   \n",
       "HN28_P6_G05_S173_comb   0.971751  0.862773  0.968909  0.953399  1.124328   \n",
       "HN26_P14_D11_S239_comb  1.100170  0.821669  0.956934  0.953593  1.119356   \n",
       "HN26_P14_H05_S281_comb  0.705589  0.977141  0.941196  0.881868  1.049143   \n",
       "HN26_P25_H09_S189_comb  1.001442  0.850375  0.874529  0.973545  1.156655   \n",
       "\n",
       "                            FTH1      ACTB    TMSB4X  MTRNR2L2       B2M  \n",
       "HN28_P15_D06_S330_comb  0.831537  1.072929  0.917554  1.167422  1.061845  \n",
       "HN28_P6_G05_S173_comb   0.923339  0.996584  0.954457  1.170053  0.940295  \n",
       "HN26_P14_D11_S239_comb  0.952363  0.821784  0.819039  1.194907  0.820894  \n",
       "HN26_P14_H05_S281_comb  0.954018  0.916003  0.984108  1.171271  1.080044  \n",
       "HN26_P25_H09_S189_comb  0.938911  0.720506  0.857750  1.227803  0.934479  \n",
       "\n",
       "[5 rows x 20684 columns]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex_matrix.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5902, 20684)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex_matrix.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>LRRC10</th>\n",
       "      <th>C12orf40</th>\n",
       "      <th>DBF4</th>\n",
       "      <th>NIPA2</th>\n",
       "      <th>BLOC1S1</th>\n",
       "      <th>BMP8A</th>\n",
       "      <th>CSF2RA</th>\n",
       "      <th>DDN</th>\n",
       "      <th>GTF2IRD2P1</th>\n",
       "      <th>KRIT1</th>\n",
       "      <th>...</th>\n",
       "      <th>PFN3</th>\n",
       "      <th>POLL</th>\n",
       "      <th>GRM5</th>\n",
       "      <th>DNASE1L1</th>\n",
       "      <th>ESR1</th>\n",
       "      <th>MIR3646</th>\n",
       "      <th>MRPL24</th>\n",
       "      <th>RPL34</th>\n",
       "      <th>RPAIN</th>\n",
       "      <th>SPAG4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>HN28_P15_D06_S330_comb</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.574693</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.056355</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.386392</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.498271</td>\n",
       "      <td>0.557611</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN28_P6_G05_S173_comb</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.440144</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.446616</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P14_D11_S239_comb</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.319468</td>\n",
       "      <td>0.326089</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.207755</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.344226</td>\n",
       "      <td>0.451720</td>\n",
       "      <td>0.273874</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P14_H05_S281_comb</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.487497</td>\n",
       "      <td>0.020447</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.012077</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.256479</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.575303</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P25_H09_S189_comb</th>\n",
       "      <td>0.010119</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.341360</td>\n",
       "      <td>0.084360</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.011687</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.377368</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.018955</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.063789</td>\n",
       "      <td>0.559325</td>\n",
       "      <td>0.322401</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 20684 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                          LRRC10  C12orf40  DBF4     NIPA2   BLOC1S1  \\\n",
       "HN28_P15_D06_S330_comb  0.000000       0.0   0.0  0.574693  0.000000   \n",
       "HN28_P6_G05_S173_comb   0.000000       0.0   0.0  0.000000  0.000000   \n",
       "HN26_P14_D11_S239_comb  0.000000       0.0   0.0  0.000000  0.319468   \n",
       "HN26_P14_H05_S281_comb  0.000000       0.0   0.0  0.000000  0.487497   \n",
       "HN26_P25_H09_S189_comb  0.010119       0.0   0.0  0.000000  0.341360   \n",
       "\n",
       "                           BMP8A    CSF2RA  DDN  GTF2IRD2P1     KRIT1  ...    \\\n",
       "HN28_P15_D06_S330_comb  0.000000  0.056355  0.0    0.000000  0.386392  ...     \n",
       "HN28_P6_G05_S173_comb   0.000000  0.000000  0.0    0.000000  0.440144  ...     \n",
       "HN26_P14_D11_S239_comb  0.326089  0.000000  0.0    0.000000  0.207755  ...     \n",
       "HN26_P14_H05_S281_comb  0.020447  0.000000  0.0    0.012077  0.000000  ...     \n",
       "HN26_P25_H09_S189_comb  0.084360  0.000000  0.0    0.000000  0.011687  ...     \n",
       "\n",
       "                        PFN3      POLL  GRM5  DNASE1L1      ESR1  MIR3646  \\\n",
       "HN28_P15_D06_S330_comb   0.0  0.000000   0.0  0.000000  0.000000      0.0   \n",
       "HN28_P6_G05_S173_comb    0.0  0.000000   0.0  0.000000  0.000000      0.0   \n",
       "HN26_P14_D11_S239_comb   0.0  0.000000   0.0  0.000000  0.000000      0.0   \n",
       "HN26_P14_H05_S281_comb   0.0  0.000000   0.0  0.000000  0.256479      0.0   \n",
       "HN26_P25_H09_S189_comb   0.0  0.377368   0.0  0.018955  0.000000      0.0   \n",
       "\n",
       "                          MRPL24     RPL34     RPAIN  SPAG4  \n",
       "HN28_P15_D06_S330_comb  0.498271  0.557611  0.000000    0.0  \n",
       "HN28_P6_G05_S173_comb   0.000000  0.446616  0.000000    0.0  \n",
       "HN26_P14_D11_S239_comb  0.344226  0.451720  0.273874    0.0  \n",
       "HN26_P14_H05_S281_comb  0.000000  0.575303  0.000000    0.0  \n",
       "HN26_P25_H09_S189_comb  0.063789  0.559325  0.322401    0.0  \n",
       "\n",
       "[5 rows x 20684 columns]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex_matrix.sample(frac=1.0, replace=False, axis=1).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>GDF6</th>\n",
       "      <th>MARVELD2</th>\n",
       "      <th>RNF123</th>\n",
       "      <th>IL20RB</th>\n",
       "      <th>C1orf106</th>\n",
       "      <th>EVC2</th>\n",
       "      <th>TWSG1</th>\n",
       "      <th>OR2A20P</th>\n",
       "      <th>TNFRSF10A</th>\n",
       "      <th>N4BP1</th>\n",
       "      <th>...</th>\n",
       "      <th>ISG20</th>\n",
       "      <th>TYR</th>\n",
       "      <th>MCOLN3</th>\n",
       "      <th>ZNF428</th>\n",
       "      <th>PTPRG</th>\n",
       "      <th>NDUFA9</th>\n",
       "      <th>RIN2</th>\n",
       "      <th>OR5C1</th>\n",
       "      <th>SLC22A13</th>\n",
       "      <th>CTSG</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>HN28_P15_D06_S330_comb</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.047957</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.687455</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.32496</td>\n",
       "      <td>0.559639</td>\n",
       "      <td>0.362015</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN28_P6_G05_S173_comb</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.441016</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.401925</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P14_D11_S239_comb</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.345828</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.054676</td>\n",
       "      <td>0.210875</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.204591</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.336877</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.414081</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.245861</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.624896</td>\n",
       "      <td>0.272417</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P14_H05_S281_comb</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.015358</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.704146</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.565675</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HN26_P25_H09_S189_comb</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.385884</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.420455</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.617900</td>\n",
       "      <td>0.261471</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 20684 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                        GDF6  MARVELD2  RNF123    IL20RB  C1orf106  EVC2  \\\n",
       "HN28_P15_D06_S330_comb   0.0  0.047957     0.0  0.000000  0.000000   0.0   \n",
       "HN28_P6_G05_S173_comb    0.0  0.000000     0.0  0.000000  0.000000   0.0   \n",
       "HN26_P14_D11_S239_comb   0.0  0.345828     0.0  0.054676  0.210875   0.0   \n",
       "HN26_P14_H05_S281_comb   0.0  0.000000     0.0  0.000000  0.015358   0.0   \n",
       "HN26_P25_H09_S189_comb   0.0  0.000000     0.0  0.000000  0.385884   0.0   \n",
       "\n",
       "                           TWSG1  OR2A20P  TNFRSF10A     N4BP1  ...   \\\n",
       "HN28_P15_D06_S330_comb  0.687455      0.0   0.000000  0.000000  ...    \n",
       "HN28_P6_G05_S173_comb   0.000000      0.0   0.000000  0.441016  ...    \n",
       "HN26_P14_D11_S239_comb  0.204591      0.0   0.336877  0.000000  ...    \n",
       "HN26_P14_H05_S281_comb  0.000000      0.0   0.000000  0.000000  ...    \n",
       "HN26_P25_H09_S189_comb  0.000000      0.0   0.000000  0.000000  ...    \n",
       "\n",
       "                           ISG20  TYR  MCOLN3    ZNF428    PTPRG    NDUFA9  \\\n",
       "HN28_P15_D06_S330_comb  0.000000  0.0     0.0  0.000000  0.32496  0.559639   \n",
       "HN28_P6_G05_S173_comb   0.000000  0.0     0.0  0.000000  0.00000  0.401925   \n",
       "HN26_P14_D11_S239_comb  0.414081  0.0     0.0  0.245861  0.00000  0.624896   \n",
       "HN26_P14_H05_S281_comb  0.704146  0.0     0.0  0.000000  0.00000  0.000000   \n",
       "HN26_P25_H09_S189_comb  0.420455  0.0     0.0  0.000000  0.00000  0.617900   \n",
       "\n",
       "                            RIN2  OR5C1  SLC22A13  CTSG  \n",
       "HN28_P15_D06_S330_comb  0.362015    0.0       0.0   0.0  \n",
       "HN28_P6_G05_S173_comb   0.000000    0.0       0.0   0.0  \n",
       "HN26_P14_D11_S239_comb  0.272417    0.0       0.0   0.0  \n",
       "HN26_P14_H05_S281_comb  0.565675    0.0       0.0   0.0  \n",
       "HN26_P25_H09_S189_comb  0.261471    0.0       0.0   0.0  \n",
       "\n",
       "[5 rows x 20684 columns]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex_matrix.sample(frac=1.0, replace=False, axis=1).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "20684"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(ex_matrix.sample(frac=1.0, replace=False, axis=1).columns.unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "20684"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(ex_matrix.columns.unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([213924270])"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(df_rnk + 1).sum(axis=1).unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "213924270.0"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(ex_matrix.shape[1]*(ex_matrix.shape[1]+1))/2.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "col1 = df_rnk.loc['HN28_P15_D06_S330_comb'].sort_values(ascending=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "col2 = ex_matrix.loc['HN28_P15_D06_S330_comb'].sort_values(ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MTRNR2L2     0\n",
       "ACTA2        1\n",
       "MTRNR2L8     2\n",
       "ACTB         3\n",
       "B2M          4\n",
       "SPARCL1      5\n",
       "TAGLN        6\n",
       "VIM          7\n",
       "IGFBP7       8\n",
       "A2M          9\n",
       "CTGF        10\n",
       "GAPDH       11\n",
       "TPM1        12\n",
       "MYL6        13\n",
       "CSRP2       14\n",
       "EEF1A1      15\n",
       "IFITM3      16\n",
       "IFITM1      17\n",
       "S100A4      18\n",
       "TMSB4X      19\n",
       "UBC         20\n",
       "RPL9        21\n",
       "FOS         22\n",
       "ACTG2       23\n",
       "TPM2        24\n",
       "Name: HN28_P15_D06_S330_comb, dtype: uint32"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "col1.head(25)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MTRNR2L2    1.167422\n",
       "ACTA2       1.146134\n",
       "MTRNR2L8    1.093898\n",
       "ACTB        1.072929\n",
       "B2M         1.061845\n",
       "SPARCL1     1.047538\n",
       "TAGLN       1.041804\n",
       "VIM         1.034850\n",
       "IGFBP7      0.980954\n",
       "A2M         0.976950\n",
       "CTGF        0.952751\n",
       "GAPDH       0.945653\n",
       "TPM1        0.941099\n",
       "MYL6        0.940129\n",
       "CSRP2       0.938331\n",
       "EEF1A1      0.925513\n",
       "IFITM3      0.924951\n",
       "IFITM1      0.921931\n",
       "S100A4      0.919569\n",
       "TMSB4X      0.917554\n",
       "UBC         0.914924\n",
       "RPL9        0.914358\n",
       "FOS         0.912780\n",
       "ACTG2       0.909681\n",
       "TPM2        0.904457\n",
       "Name: HN28_P15_D06_S330_comb, dtype: float64"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "col2.head(25)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.6.4 (pyscenic_dev)",
   "language": "python",
   "name": "pyscenic_dev"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
